//function showValue(newValue) {
//	document.getElementById("range").innerHTML = newValue;
//}
//function showValue1(newValue) {
//	document.getElementById("range1").innerHTML = newValue;
//}
//function compareCommute(form) {
//	var startDate = form.demo1.value;  
//	var endDate = form.demo2.value; 
//	var startRadius = document.getElementById("range").innerHTML;
//	var endRadius = document.getElementById("range1").innerHTML;
//	 var cbResults = null;
//	 
//	    var radioResults = 'Radio buttons: ';
//	    for (var i = 0; i < form.elements.length; i++ ) {
//	        if (form.elements[i].type == 'checkbox') {
//	            if (form.elements[i].checked == true) {
//	                cbResults += form.elements[i].value + ' ';
//	            }
//	        }
//	        if (form.elements[i].type == 'radio') {
//	            if (form.elements[i].checked == true) {
//	                radioResults += form.elements[i].value + ' ';
//	            }
//	        }
//	     
//	    }
//	  
//	    location.href = "/SocialCommuting/CompareCommute?startDate=" + startDate +"&endDate="+ endDate+"&checkBoxVal="+cbResults+"&startRadius=" + startRadius + "&endRadius=" + endRadius; 
//}
var mapSec;
function showValue(newValue) {
	document.getElementById("range").innerHTML = newValue;
}
function showValue1(newValue) {
	document.getElementById("range1").innerHTML = newValue;
}
function compareCommute(form) {
	
	var sTimeValue = form.sTime.value;
	var eTimeValue = form.eTime.value;
	var sLatValue = form.sLat.value;
	var sLngValue = form.sLng.value;
	var eLatValue = form.eLat.value;
	var eLngValue = form.eLng.value;
	var sRadiusValue = form.sRadius.value;
	var eRadiusValue = form.eRadius.value;
	var CBoxValue = form.CBoxTransportModes.value;
	

	
	var startDate = form.demo1.value;  
	var endDate = form.demo2.value; 
	
	var startRadius = document.getElementById("range").innerHTML;
	var endRadius = document.getElementById("range1").innerHTML;
	var cbResults = null;
	var cityDDMap2 = form.cityDropdownPick1.value;
	
	
	var cityDDMap1 = form.city.value;
	
	//var cityDDMap1 = form.cityDropdownPick.value;
	
	
	
	    var radioResults = 'Radio buttons: ';
	    for (var i = 0; i < form.elements.length; i++ ) {
	        if (form.elements[i].type == 'checkbox') {
	            if (form.elements[i].checked == true) {
	                cbResults += form.elements[i].value + ' ';
	            }
	        }
	        if (form.elements[i].type == 'radio') {
	            if (form.elements[i].checked == true) {
	                radioResults += form.elements[i].value + ' ';
	            }
	        }
	     
	    }
//	   local host use change to server use code
	    
//	    location.href = "/SocialCommuting/CompareCommute?startDate=" + startDate +"&endDate="+ endDate+"&checkBoxVal="+cbResults+"&startRadius=" + startRadius + "&endRadius=" + endRadius+ "&slat="
//		+ $('#input-slat').val() + "&slng=" + $('#input-slng').val()
//		+ "&elat=" + $('#input-slat').val() + "&elng="
//		+ $('#input-slng').val()
//		+"&sTime="+sTimeValue+"&eTime="+eTimeValue 
//		+"&sLat="+sLatValue +"&sLng="+sLngValue 
//		+"&eLat="+eLatValue+"&eLng="+eLngValue
//		+"&sRadius="+sRadiusValue+"&eRadius="+eRadiusValue
//		+"&CBoxTransportModes="+CBoxValue
//		;
	    
	    location.href = "/it/CompareCommute?startDate=" + startDate +"&endDate="+ endDate+"&checkBoxVal="+cbResults+"&startRadius=" + startRadius + "&endRadius=" + endRadius+ "&slat="
		+ $('#input-slat').val() + "&slng=" + $('#input-slng').val()
		+ "&elat=" + $('#input-slat').val() + "&elng="
		+ $('#input-slng').val()
		+"&sTime="+sTimeValue+"&eTime="+eTimeValue 
		+"&sLat="+sLatValue +"&sLng="+sLngValue 
		+"&eLat="+eLatValue+"&eLng="+eLngValue
		+"&sRadius="+sRadiusValue+"&eRadius="+eRadiusValue
		+"&CBoxTransportModes="+CBoxValue
		+"&cityDDMap2="+cityDDMap2
		+"&cityDDMap1="+cityDDMap1
		;

	    
}

$(document).ready(function() {
	initializeSecMap();

});


//function initializeSecMap() {
//    //var myLatlng = new google.maps.LatLng(57.7001953125, 11.93115234375);
//    var myLatlng = new google.maps.LatLng(19.429413676234212, -99.12683863302618);
//    var myOptions = {
//      zoom: 12,
//      center: myLatlng,
//      mapTypeId: google.maps.MapTypeId.ROADMAP
//    }
//   
//    map = new google.maps.Map(document.getElementById("map_canvasSec"), myOptions);
//  
//}




function initializeSecMap() {
	

	
	
	
	

	var myLatlng;
	var myOptions1 = {
		center : new google.maps.LatLng(57.70779280783442, 11.937975883483887),
		zoom : 12,
		mapTypeId : google.maps.MapTypeId.ROADMAP
	};
	var myOptions2 = {
		center : new google.maps.LatLng(19.429413676234212, -99.12683863302618),
		zoom : 12,
		mapTypeId : google.maps.MapTypeId.ROADMAP
	};

	$("#cityDropdownPick1").change(function () {
		$("select option:selected").each(function () {
			if ($('#cityDropdownPick1').val() == "gothenborg") {
				mapSec = new google.maps.Map(document.getElementById("map_canvasSec"),myOptions1);
				


				var infoWindow = new google.maps.InfoWindow();

				google.maps.event.addListener(mapSec, 'click',
						function(event) {

							var html = 'The LatLng value is: ' + event.latLng
									+ ' at zoom level ' + map.getZoom();
							infoWindow.setContent(html);
							infoWindow.setPosition(event.latLng);

							if ($('#input-slat').val() == ""
									&& $('#input-elat').val() == "") {
								$('#input-slat').val(event.latLng.lat());
								$('#input-slng').val(event.latLng.lng());
							} else if ($('#input-slat').val() != ""
									&& $('#input-elat').val() == "") {
								$('#input-elat').val(event.latLng.lat());
								$('#input-elng').val(event.latLng.lng());
							} else if ($('#input-slat').val() != ""
									&& $('#input-elat').val() != "") {
								$('#input-slat').val('');
								$('#input-slng').val('');
								$('#input-elat').val('');
								$('#input-elng').val('');
								$('#input-slat').val(event.latLng.lat());
								$('#input-slng').val(event.latLng.lng());
							}
							
							infoWindow.open(mapSec);
						});
				// javascript:void(prompt('',gApplication.getMap().getCenter()));
				javascript: void (prompt('', gApplication.getMap().getCenter()));
			} else if ($('#cityDropdownPick1').val() == "mexico") {
				mapSec = new google.maps.Map(document.getElementById("map_canvasSec"),
						myOptions2);
				

				var infoWindow = new google.maps.InfoWindow();

				google.maps.event.addListener(mapSec, 'click',
						function(event) {

							var html = 'The LatLng value is: ' + event.latLng
									+ ' at zoom level ' + map.getZoom();
							infoWindow.setContent(html);
							infoWindow.setPosition(event.latLng);

							if ($('#input-slat').val() == ""
									&& $('#input-elat').val() == "") {
								$('#input-slat').val(event.latLng.lat());
								$('#input-slng').val(event.latLng.lng());
							} else if ($('#input-slat').val() != ""
									&& $('#input-elat').val() == "") {
								$('#input-elat').val(event.latLng.lat());
								$('#input-elng').val(event.latLng.lng());
							} else if ($('#input-slat').val() != ""
									&& $('#input-elat').val() != "") {
								$('#input-slat').val('');
								$('#input-slng').val('');
								$('#input-elat').val('');
								$('#input-elng').val('');
								$('#input-slat').val(event.latLng.lat());
								$('#input-slng').val(event.latLng.lng());
							}
							
							infoWindow.open(mapSec);
						});
				javascript: void (prompt('', gApplication.getMap().getCenter()));
			}
          });
	  }).change();
	
}